package day23;

import java.io.*;

//测试复制粘贴功能
public class Demo5 {
    public static void main(String[] args) {
        File in=new File("C:\\Users\\梅穿内裤\\Desktop\\qq\\特效素材.zip");
        File out=new File("C:\\Users\\梅穿内裤\\Desktop\\qq\\dd\\test.zip");
        if(in.exists()){
            File pOut=out.getParentFile();
            if (!pOut.exists()) pOut.mkdirs();
            FileInputStream fis=null;
            FileOutputStream fos=null;
            try {
                long start=System.currentTimeMillis();
                fis=new FileInputStream(in);
                fos=new FileOutputStream(out);
                byte bs[]=new byte[1024];
                int len=0;
                while ((len=fis.read(bs))!=-1){
                    fos.write(bs,0,len);
                }
                long end=System.currentTimeMillis();
                System.out.println("复制成功，消耗的时间:"+(end-start)+"ms");
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    fis.close();
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }else {
            System.out.println("读取文件不存在");
        }
    }
}
